<template>
  <el-switch
    v-model="current_field"
    :active-text="$util.getDefValue(current_args.active_text, '')"
    :active-value="$util.getDefValue(current_args.active_value, '1')"
    :inactive-text="$util.getDefValue(current_args.inactive_text, '')"
    :inactive-value="$util.getDefValue(current_args.inactive_value, '0')"
    :disabled="disabledValue"
  />
</template>
<script>
export default {
  props: {
    value: {
      type: String,
      default: ''
    },
    args: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  data() {
    return {
      current_field: this.value,
      current_args: this.args
    };
  },
  computed: {
    disabledValue() {
      if (this.current_args.disabled == '1') {
        return true;
      }

      return null;
    }
  },
  watch: {
    current_field(value) {
      this.$emit('update:value', value);
    },
    value: {
      handler(now, old) {
        this.current_field = now;
      }
    }
  }
};
</script>
